package cn.gxljc.technology.store_management.mapper;

import cn.gxljc.technology.store_management.entity.WarehouseStock;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*
 **@author LuoShengYing
 **@date 2021/6/19
 * WarehouseStockMapper用于管理WarehouseStock(仓库库存)表
 */
@Mapper
public interface WarehouseStockMapper {

    // 通过wareID，查询所有仓库对应商品的库存信息
    @Select("select * from `warehousestock` where `wareID` = #{wareID}")
    List<WarehouseStock> selectStockByWareID(int wareID);

    // 通过warehouseID，查询仓库所有商品的库存信息
    @Select("select * from `warehousestock` where `warehouseID` = #{warehouseID}")
    List<WarehouseStock> selectStockByWarehouseID(int warehouseID);

    // 通过wareID和warehouseID，查询对应仓库的对应商品库存
    @Select("select * from `warehousestock` where `wareID` = #{wareID} and `warehouseID` = #{warehouseID}")
    WarehouseStock selectStockByWareIDAndWarehouseID(int wareID, int warehouseID);

    // 新增warehouseStock数据，并返回boolean类型数据显示成功与否
    @Insert("insert `warehousestock` set `warehouseID` = #{warehouseID}, `wareID` = #{wareID}, `wareCount` = #{wareCount}")
    boolean insertStock(WarehouseStock warehouseStock);

    // 通过wareID和warehouseID，更新warehouseStock中的wareCount数据，并返回boolean类型数据显示成功与否
    @Delete("delete from `warehousestock` where `wareID` = #{wareID} and `warehouseID` = #{warehouseID}")
    boolean updateStockByWareIDAndWarehouseID(int wareID, int warehouseID, int wareCount);

    // 通过wareID和warehouseID，删除warehouseStock数据，并返回boolean类型数据显示成功与否
    boolean deleteStockByWareIDAndWarehouseID(int wareID ,int warehouseID);
}
